package com.zhu.controller.system;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhu.pojo.Loginlog;
import com.zhu.query.LoginLogQuery;
import com.zhu.service.ILoginlogService;
import com.zhu.utils.IpUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;


/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author xiaozhu
 * @since 2022-09-30
 */
@RestController
@RequestMapping("/loginLog")
public class LoginlogController {

    @Autowired
    private ILoginlogService loginlogService;

    @InitBinder
    public void initBinder(WebDataBinder webDataBinder) {
        webDataBinder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true));
    }

    @RequestMapping("/all")
    public List<Loginlog> getLoginLog(LoginLogQuery loginLogQuery) {
        return loginlogService.getLog(loginLogQuery);
    }

}
